import { useDispatch } from "react-redux";
import { useHistory } from "react-router";
import actions from "../store/actions";

export default () => {
    const dispatch = useDispatch();
    const { push } = useHistory();
    return (
        <>
            <button
                onClick={() => {
                    dispatch({
                        type: actions.login.login,
                    });

                    const prevpath = localStorage.getItem("prevpath");
                    if (prevpath) {
                        push(prevpath);
                    }
                }}
            >
                登录
            </button>
        </>
    );
};
